package cn.flying.cloud.demo.jobs;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.UUID;

import cn.flying.cloud.base.common.utils.Ft;
import cn.flying.cloud.task.core.annotation.JobHandler;
import cn.flying.cloud.task.core.exception.TaskException;
import cn.flying.cloud.task.core.model.JobContext;

import cn.flying.cloud.task.core.handler.AbstractJobHandler;
import cn.flying.cloud.task.entity.CpApplicationInfo;
import cn.flying.cloud.task.service.CpApplicationInfoService;

import javax.annotation.Resource;

/**
 * @author: admin
 * @date: 2024年06月06日 19:26
 * @version: 1.0
 */
@JobHandler(name = "demoJob")
public class DemoJob extends AbstractJobHandler {

    @Resource
    private CpApplicationInfoService applicationInfoService;

    /**
     * 执行
     */
    @Override
    public void execute(JobContext context) throws TaskException {
        logger.info("执行了。。。");
        for (int i = 0; i < 20; i++) {
            CpApplicationInfo applicationInfo = new CpApplicationInfo();
//            applicationInfo.setId(0L);
            applicationInfo.setAppNo(Ft.DateTime.formatLocalDateTime(LocalDateTime.now(), Ft.DateTime.DATE_TIME_FORMAT_2) + i);
            applicationInfo.setName("张三" + (i + 1));
            applicationInfo.setGender("男");
            applicationInfo.setAge(25);
            applicationInfo.setBirthday(LocalDate.now());
            applicationInfo.setNationality("中国");
            applicationInfo.setCreatedBy("system");
            applicationInfo.setCreatedTime(LocalDateTime.now());
            applicationInfo.setUpdatedBy("system");
            applicationInfo.setUpdatedTime(LocalDateTime.now());
            applicationInfo.setTenantId("10000");
            applicationInfo.setRevision(0L);
//            applicationInfo.setDeleted("");

            applicationInfoService.createObj(applicationInfo);
        }
        System.out.println("demoJob任务执行了。。。。");
        System.out.println(context);
    }
}
